package main

import "fmt"

/**
 * @author: guangcheng
 * @date:   2020/11/18 16:26
 * @version  V1.0
 * @description:
 *
 */
func main() {
	students := make(map[string]Stu, 1)
	//容量虽然是1, 但是可以动态扩容
	stu1 := Stu{"tom", 19, "北京"}
	stu2 := Stu{"cat", 9, "北京"}
	students["no01"] = stu1
	students["no02"] = stu2

	//map[no01:{tom 19 北京} no02:{cat 9 北京}]
	fmt.Println(students)

	changeMapEle(students)
	//map[no01:{hello 10 sh} no02:{cat 9 北京}]
	fmt.Println(students)
}

/**
结构体
*/
type Stu struct {
	Name    string
	Age     int
	Address string
}

//map是引用类型,传的是应用,修改会改变原来的值
func changeMapEle(map1 map[string]Stu) {

	map1["no01"] = Stu{"hello", 10, "sh"}
	return
}
